package cn.hx.admin.controller;

import cn.hx.admin.entity.JobLog;
import cn.hx.admin.service.JobLogService;

import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
 * 定时任务调度日志表(JobLog)表控制层
 *
 * @author makejava
 * @since 2023-12-10 20:34:21
 */
@RestController
@RequestMapping("jobLog")
public class JobLogController {
    /**
     * 服务对象
     */
    @Resource
    private JobLogService jobLogService;

    /**
     * 分页查询
     *
     * @param jobLog 筛选条件
     * @return 查询结果
     */
    @GetMapping
    @PreAuthorize("hasAuthority('system:scheduleLog:list')")
    public ResponseEntity<List<JobLog>> queryByPage(JobLog jobLog) {
        return ResponseEntity.ok(this.jobLogService.queryByPage(jobLog));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    @PreAuthorize("hasAuthority('monitor:log:query')")
    public ResponseEntity<JobLog> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.jobLogService.queryById(id));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    @PreAuthorize("hasAuthority('monitor:log:delete')")
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.jobLogService.deleteById(id));
    }

}

